package com.slwish.xty.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.slwish.common.utils.TimeUtils;
import com.slwish.xty.R;
import com.slwish.xty.entity.SubscribeModel;

import java.util.List;

import static com.slwish.xty.utils.ResourceUtils.getString;


/**
 * 模块说明：
 *
 * @author 陈浩
 * @date 2017/12/5
 */

public class SubscribeListAdapter extends BaseQuickAdapter<SubscribeModel,BaseViewHolder> {
    public SubscribeListAdapter(@Nullable List<SubscribeModel> data) {
        super(R.layout.item_subscribe_list,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, SubscribeModel item) {
//        helper.setOnClickListener(R.id.tv_qd,new OnItemChildClickListener());
        helper.setText(R.id.tv_name,item.getScenicName())
                .setText(R.id.tv_rz_time,String.format(mContext.getString(R.string.rz_text), TimeUtils.getStringTime(item.getResideTime())))
                .setText(R.id.tv_lk_time,String.format(mContext.getString(R.string.lk_text), TimeUtils.getStringTime(item.getDepartureTime())))
                .setText(R.id.tv_rz_rs,String.format(getString(R.string.zsrs_text), item.getDinersNum()))
                .setText(R.id.tv_jc_rs,String.format(getString(R.string.jcrs_text), item.getStayNum()))
                .setText(R.id.tv_lxr,String.format(getString(R.string.lxr_content_text), item.getLinkman()))
                .setText(R.id.tv_lxdh,String.format(getString(R.string.lxdh_content_text), item.getPhone()))
                .addOnClickListener(R.id.tv_qd);

        TextView tv_status = helper.getView(R.id.tv_status);
        TextView tv_qd = helper.getView(R.id.tv_qd);
        if (TextUtils.equals(item.getStatus(),"2")&&TextUtils.equals(item.getSignIn(),"0")){
            tv_status.setText(R.string.yy_success_title);
            tv_qd.setText(R.string.sign_text);
        }else if(TextUtils.equals(item.getStatus(),"3")&&TextUtils.equals(item.getSignIn(),"0")){
            tv_status.setText(R.string.yy_failed_title);
            tv_qd.setText(R.string.re_appointment_text);
        }else if(TextUtils.equals(item.getStatus(),"4")&&TextUtils.equals(item.getSignIn(),"0")){
            tv_status.setText(R.string.cancel_subscribe_text);
            tv_qd.setText(R.string.re_appointment_text);
        }
        else if(TextUtils.equals(item.getStatus(),"5")&&TextUtils.equals(item.getSignIn(),"0")){
            tv_status.setText(R.string.failed_text);
            tv_qd.setText(R.string.re_appointment_text);
        }
        else if(TextUtils.equals(item.getStatus(),"8")&&TextUtils.equals(item.getSignIn(),"1")
                &&TextUtils.equals(item.getIsCommented(),"0")){
            tv_status.setText(R.string.completed_text);
            tv_qd.setText(R.string.re_appointment_text);
        }
        else if(TextUtils.equals(item.getStatus(),"6")&&TextUtils.equals(item.getSignIn(),"1")){
            tv_status.setText(R.string.have_signed_in_text);
            tv_qd.setText(R.string.re_appointment_text);
        }
        else if(TextUtils.equals(item.getStatus(),"8")&&TextUtils.equals(item.getSignIn(),"1")
                &&TextUtils.equals(item.getIsCommented(),"1")){
            tv_status.setText(R.string.have_evaluated_text);
            tv_qd.setText(R.string.re_appointment_text);
        }


    }
}
